import 'package:native_dart_package/http/request/exception/api_exception.dart';
import 'package:yt_devops/configs.dart';
import 'package:yt_devops/pages/tasks/finish_report_task/finish_report_task_binding.dart';

import '../predicates.dart';

class TaskServices {
  Future getInstallTaskList(params) {
    return Configs.httpClient
        .get('$oss/installationWorkOrder/list', queryParameters: params);
  }

  Future getRepairTaskList(params) {
    return Configs.httpClient
        .get('$oss/maintenanceWorkOrder/list', queryParameters: params);
  }

  Future getReportTaskList(params) {
    return Configs.httpClient
        .get('$oss/obstacleReport/list', queryParameters: params);
  }

  Future getInstallTaskDetail(params) {
    return Configs.httpClient
        .get('$oss/installationWorkOrder/details', queryParameters: params);
  }

  Future getRepairTaskDetail(params) {
    return Configs.httpClient
        .get('$oss/maintenanceWorkOrder/details', queryParameters: params);
  }

  Future getReportTaskDetail(params) {
    return Configs.httpClient
        .get('$oss/obstacleReport/detail', queryParameters: params);
  }

  //接收工单
  // 接收安装单
  Future acceptInstallTask(params) {
    return Configs.httpClient
        .put('$oss/installationWorkOrder/accept', data: params);
  }

  //接收维修单
  Future acceptRepairTask(params) {
    return Configs.httpClient
        .put('$oss/maintenanceWorkOrder/accept', data: params);
  }

  //接收报障单
  Future acceptReportTask(params) {
    return Configs.httpClient
        .put('$oss/obstacleReport/startExecution', data: params);
  }

  //安装人列表
  Future getInstallerList(params, bool Function(ApiException)? onError) {
    return Configs.httpClient.get(
        '$system/customerUser/maintainerOrInstaller/List',
        queryParameters: params,
        onError: onError);
  }

  //安装商列表
  Future getInstallProvideList(params, bool Function(ApiException)? onError) {
    return Configs.httpClient.get('$uc/customerUser/serviceProvider/page',
        queryParameters: params, onError: onError);
  }

  /// 报障单选择的接收人列表
  Future maintainerList(params, {bool Function(ApiException)? onError}) {
    return Configs.httpClient.get('$system/customerUser/maintainer/page',
        queryParameters: params, onError: onError);
  }

  /// 维护客户名称
  Future customerList(params, {bool Function(ApiException)? onError}) {
    return Configs.httpClient.get('$uc/customerUser/maintainer/user/page',
        queryParameters: params, onError: onError);
  }

  // 工单处理结果
  //安装工单
  Future getInstallDealResults(params) {
    return Configs.httpClient.get('$oss/installationWorkOrder/getTriggerEvent',
        queryParameters: params);
  }

  ///处理工单
  ///
  ///安装
  Future transitInstallTask(params) {
    return Configs.httpClient
        .put('$oss/installationWorkOrder/transit', data: params);
  }

  ///安装
  Future finishReportTask(params) {
    return Configs.httpClient.put('$oss/obstacleReport/complete', data: params);
  }

  //维修单
  Future transitRepairTask(params) {
    return Configs.httpClient
        .put('$oss/maintenanceWorkOrder/transit', data: params);
  }

  //报障单
  Future transitReportTask(params) {
    return Configs.httpClient.put('$oss/obstacleReport/transit', data: params);
  }

  ///完成工单
  ///
  ///安装单
  Future completeInstall(params) {
    return Configs.httpClient
        .put('$oss/installationWorkOrder/complete', data: params);
  }

  ///维护单
  Future completeRepair(params) {
    return Configs.httpClient
        .put('$oss/maintenanceWorkOrder/complete', data: params);
  }

  ///创建工单
  ///
  ///安装单
  Future createInstall(params) {
    return Configs.httpClient
        .post('$oss/installationWorkOrder/create', data: params);
  }

  /// 维护单
  Future createRepair(params) {
    return Configs.httpClient
        .post('$oss/maintenanceWorkOrder/create', data: params);
  }

  /// 报障单
  Future createObstacleReport(params) {
    return Configs.httpClient.post('$oss/obstacleReport/create', data: params);
  }

  /// 报障单
  Future createRepairByReport(params) {
    return Configs.httpClient
        .post('$oss/obstacleReport/createMaintenance', data: params);
  }

  /// 编辑工单
  ///
  /// 安装单
  Future editInstall(params) {
    return Configs.httpClient
        .put('$oss/installationWorkOrder/edit', data: params);
  }

  Future editRepair(params) {
    return Configs.httpClient
        .put('$oss/maintenanceWorkOrder/edit', data: params);
  }
}
